#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/5
import socket

ip_port = ("127.0.0.1", 9999)

sk = socket.socket()
sk.connect(ip_port)

sk.sendall(bytes("请占领地球", encoding="utf8"))
server_reply = sk.recv(1024)
print(str(server_reply, "utf8"))
while True:
    user_input = input(">>:").strip()  # 接收用户输入
    sk.send(bytes(user_input, "utf8"))  # 转码，发送
    server_reply = sk.recv(1024)  # 接收服务器回应
    print(str(server_reply, "utf8"))

sk.close()
